package com.eaoa.query.pub;

import java.util.Collection;

import org.hibernate.HibernateException;

import com.eaoa.base.EABaseQuery;
import com.eaoa.vo.pub.PubModule;

public class PubModuleQuery extends EABaseQuery {

	public PubModuleQuery() {

		super(PubModule.class);
		noCheckOutOfMemory();
		addInnerJoin(1, "pubRoles", "pubRoles");
		addInnerJoin(2, "pubAccounts", "pubRoles.pubAccounts", 1);

	}
	
	
	public void setASCOrderno(String val) {
		setASCOrder(val);
	}
	

	public void setEmployeeno(Long employeeno) {
		setEQCondition("pubAccounts.accountno", employeeno);
	}
	
	public void setModuleno(Long  moduleno) {
		setEQCondition("moduleno", moduleno);
	}
	
	public void setModuleno(Collection  val) {
		setINCondition("moduleno", val);
	}
	
	public void setModulenamecn(String modulenamecn) {
		setLIKECondition("modulenamecn", modulenamecn);
	}

	public void setIsmenu(String val) {
		setEQCondition("ismenu", val);
	}

	public void setEQModuletype(String val) {
		setEQCondition("moduletype", val);
	}

	public void setNOEQModuletype(String val) {
		setNOEQCondition("moduletype", val);
	}
	
	public void setModuletypeIN(String[] val){
		setINCondition("moduletype", val);
	}

	public void setBetweenModuletype(String val, String val1) {
		buildNumberBetweenCondition("moduletype", val, val1);
	}

	public void setParentno(Long val) {
		setEQCondition("parentno", val);
	}

	public void setNotParentno(Long val) {
		setNOEQCondition("parentno", val);
	}

	public void setUrlpath() {
		setISNULLCondition("urlpath");
	}

	public void setNOTUrlpath() {
		setISNOTNULLCondition("urlpath");
	}

	public void setUrlpath(String url) {
		setEQCondition("urlpath",url);
	}

	
	public void setRoleno(Long val) {
		setEQCondition("pubRoles.roleno", val);
	}
	
	public void setIslock(String val) {
		setEQCondition("islock", val);
	}

	public void fetchSysRoles() {
		setLeftJoinFetchs(" inner join fetch this.pubRoles");
	}

	protected void lazeInit() throws HibernateException {

		super.lazeInit();

	}
	
public static PubModule loadByNo(Long moduleno){
	PubModuleQuery query =new PubModuleQuery();
	query.setModuleno(moduleno);
	query.execute();
	
	if(query.getResults().size()!=1){
		return null;
	}
	
	return (PubModule)query.getResults().get(0);
}
}
